<!-- 分享海报 -->
<template>
  <van-popup class="sharePopup" v-model="sharePopup" @closed="closed" closeable close-icon-position="bottom-right" style="background-color: transparent;">
    <div class="sharePopup-box">
      <div class="sharePopup-bg">
        <img class="posterImg" :src="img" alt="" />
        <div class="text text-down">长按保存图片</div>
        <div class="poster-url">
          <input type="text" :value="url" />
          <div class="poster-down" @click.stop v-clipboard:copy="url" v-clipboard:success="onCopy">复制</div>
        </div>
      </div>
      <div class="text-desc">用户打开链接或图片，生成自己分享的海报，邀请好友。</div>
      
    </div>
  </van-popup>
</template>

<script>
export default {
  model: {
    prop: "sharePopup",
    event: "onEmit"
  },
  props: {
    img: {
      type: String,
      default: ""
    },
    pid: {
      type: String,
      default: ""
    },
    sharePopup: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      url: ""
    };
  },

  activated() {},

  components: {},

  computed: {},

  mounted() {},
  watch: {
    sharePopup: function(newV, oldV) {
      this.url = this.fun.getSiteRoot() + "/addons/yun_shop/?menu#/member/gduEnterprisePoster/" + this.pid + "?i=" + this.fun.getKeyByI() + "&mid=" + this.fun.getKeyByMid();
    }
  },

  methods: {
    onCopy() {
      this.$toast("复制成功");
    },
    closed() {
      this.$emit("onEmit", false);
    }
  }
};
</script>
<style lang="scss" rel="stylesheet/scss" scoped>
.sharePopup-box {
  // width: 16.875rem;
  width: 280px;
  // width:70%;
  // background-color: #fff;
  background: #F5F5F5;
  border-radius: 0.313rem;
  border-radius: 15px;
  margin-bottom: 40px;
  .sharePopup-bg {
    padding: 1rem 0.625rem;
    background-color: #fff;
    border-radius: 15px;
  }
  .posterImg {
    margin-bottom: 0.625rem;
    width: 260px;
    background-color: #e8e8e8;
    // border-radius: 0.313rem;
    border-radius: 12px 12px 12px 12px;
  }
  
  .text {
    text-align: left;
    font-size: 0.688rem;
    color: #202020;
    margin-bottom: 0.625rem;
  }
  .text-down {
    font-size: 12px;
    color: #6E6E79;
    text-align: center;
  }
  .text-desc {
    font-size: 12px;
    color: #6E6E79;
    line-height: 18px;
    padding:13px 14px 13px 14px;
    text-align: left;
  }

  .poster-url {
    display: flex;
    background: #FFFFFF;
    border-radius: 8px 8px 8px 8px;
    border: 1px solid #D6D6DC;
    
    .poster-down {
      font-size: 12px;
      color: #F15353;
      line-height: 18px;
      padding:10px 10px 10px 0;
    }
  }

  input {
    flex: 1;
    // height: 24px;
    padding: 0 0.5rem;
    font-size: 0.625rem;
    background-color: transparent;
    border: none;
    margin-right: 0.625rem;
    font-weight: 400;
    font-size: 11px;
    color: #00001C;
  }
}

.sharePopup {
  ::v-deep .van-popup__close-icon {
    right: 125px;
    bottom: 0;
    padding: 4px;
    font-size: 14px;
    color: #fff;
    border: 2px solid #fff;
    font-weight: 600;
    border-radius: 50%;
  }
}
</style>
